Vector is base class of other vector like classes. It represents a series of vectors.
from py3d import Vector
Vector()
Vector([], dtype=float64)
Vector([0, 0, 0, 0])
Vector([0, 0, 0, 0])
Vector([1, 2, -4])
Vector([ 1, 2, -4])
Vector([1, 2, 3], (2,))
Vector([[1, 2, 3],
[1, 2, 3]])
import py3d
py3d.Vector([1, 2, 0, 3], ())
Vector([1, 2, 0, 3])
Vector([1], (2,))
Vector([[1],
[1]])
Get unit vector
import py3d
V32 = py3d.Vector([
[1, 3],
[2, -9],
[0.1, -3]])
V32
V32.U
Vector([[ 0.31622777, 0.9486833 ],
[ 0.21693046, -0.97618706],
[ 0.03331483, -0.99944491]])
Get length of vectors
V32.L
array([[3.16227766],
[9.21954446],
[3.0016662 ]])
from numpy import allclose
assert allclose(V32.U.L, [[1], [1], [1]])
Get homogeneous vector
V32.H
Vector3([[ 1. , 3. , 1. ],
[ 2. , -9. , 1. ],
[ 0.1, -3. , 1. ]])
Get a series of random vectors
import py3d
py3d.Vector.Rand(2,3,4)
Vector([[[0.46717877, 0.03850093, 0.00723902, 0.6500078 ],
[0.07587292, 0.10618961, 0.96764212, 0.87053555],
[0.34052838, 0.22340301, 0.24048443, 0.70709521]],
[[0.36072263, 0.80044308, 0.75300266, 0.87986896],
[0.72632113, 0.84759755, 0.54220288, 0.428758 ],
[0.96878864, 0.89251914, 0.4613795 , 0.93576249]]])
import py3d
py3d.Vector([[0,0],[1,2],[3,4]]).diff()
Vector([[1, 2],
[2, 2]])
Read pcd file
import py3d
py3d.read_pcd("ascii.pcd").xyz.as_point()
import py3d
pcd = py3d.read_pcd("binary.pcd")
points = pcd.xyz.as_point()
points.color = py3d.Color.map(pcd.intensity, 0, 255)
points